package com.coolwen.service;

import com.coolwen.dao.GoodsTypeMapper;
import com.coolwen.dao.GroupMapper;
import com.coolwen.entity.GoodsType;
import com.coolwen.entity.Group;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by user on 2016-11-10.
 */
@Service("groupService")
public class GroupServiceImpl implements GroupService {
    @Autowired
    GroupMapper groupMapper;
    //引入log4j,进行日志打印
    private static final Logger LOGGER = Logger.getLogger(GroupServiceImpl.class);


    @Override
    public Group findByGroupId(Integer groupId) {
        return groupMapper.selectByPrimaryKey(groupId);
    }

    @Override
    public List<Group> findGroupByRequest(String requestType, String requestValue) {
        return null;
    }

    @Override
    public int deleteByGroupId(Integer groupId) {
        return groupMapper.deleteByPrimaryKey(groupId);
    }

    @Override
    public int updateGroupByGroupId(Group group) {
        return groupMapper.updateByPrimaryKeySelective(group);
    }

    @Override
    public int addGroup(Group group) {
        return groupMapper.insertSelective(group);
    }

    @Override
    public List<Group> findAllGroup() {
        return  groupMapper.selectAllGroup();
    }

    @Override
    public List<Group> findByInitiatorId(Integer initiatorId) {
        return groupMapper.selectByInitiatorId(initiatorId);
    }

    @Override
    public List<Group> findByTypeId(Integer typeId) {
        return groupMapper.selectGroupByTypeId(typeId);
    }

    @Override
    public List<Group> findByUserId(Integer userId) {
        return groupMapper.selectGroupByUserId(userId);
    }

    @Override
    public List<Group> findByStateAndInitiatorId(Integer groupState,Integer groupInitiatorId) {
        return groupMapper.selectGroupByStateAndGroupInitiatorId(groupState, groupInitiatorId);
    }

    @Override
    public List<Group> findByStateAndUserId(Integer groupState, Integer userId) {
        return groupMapper.selectGroupByStateAndUserId(groupState,userId);
    }
}
